/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, {
/******/ 				configurable: false,
/******/ 				enumerable: true,
/******/ 				get: getter
/******/ 			});
/******/ 		}
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
    value: true
});
var Map = L.Class.extend({
    initialize: function initialize(map) {
        var _this = this;

        this.map = map;
        this.Draw = new L.PM.Draw(map);
        this.Toolbar = new L.PM.Toolbar(map);

        this.map.on('layerremove', function (e) {
            if (e.layer.pm && !e.layer._pmTempLayer) {
                _this.map.fire('pm:remove', e);
            }
        });
    },
    addControls: function addControls(options) {
        this.Toolbar.addControls(options);
    },
    removeControls: function removeControls() {
        this.Toolbar.removeControls();
    },
    toggleControls: function toggleControls() {
        this.Toolbar.toggleControls();
    },
    controlsVisible: function controlsVisible() {
        return this.Toolbar.isVisible;
    },
    enableDraw: function enableDraw() {
        var shape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Poly';
        var options = arguments[1];

        this.Draw.enable(shape, options);
    },
    disableDraw: function disableDraw() {
        var shape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Poly';

        this.Draw.disable(shape);
    },
    setPathOptions: function setPathOptions(options) {
        this.Draw.setPathOptions(options);
    },
    removeLayer: function removeLayer(e) {
        var layer = e.target;
        if (!layer._layers && (!layer.pm || !layer.pm.dragging())) {
            e.target.remove();
        }
    },
    toggleGlobalRemovalMode: function toggleGlobalRemovalMode() {
        var _this2 = this;

        // toggle global edit mode
        if (this.globalRemovalEnabled()) {
            this._globalRemovalMode = false;
            this.map.eachLayer(function (layer) {
                layer.off('click', _this2.removeLayer);
            });
        } else {
            this._globalRemovalMode = true;
            this.map.eachLayer(function (layer) {
                if (layer.pm) {
                    layer.on('click', _this2.removeLayer);
                }
            });
        }

        // toogle the button in the toolbar
        this.Toolbar.toggleButton('deleteLayer', this._globalRemovalMode);
    },
    globalRemovalEnabled: function globalRemovalEnabled() {
        return this._globalRemovalMode;
    },
    globalEditEnabled: function globalEditEnabled() {
        return this._globalEditMode;
    },
    enableGlobalEditMode: function enableGlobalEditMode(options, editLayer) {
        // find all layers handles by leaflet.pm
        var layers = [];
        if (editLayer) {
            layers.push(editLayer);
        } else {
            this.map.eachLayer(function (layer) {
                if (layer instanceof L.Polyline || layer instanceof L.Marker || layer instanceof L.Circle) {
                    layers.push(layer);
                }
            });
        }

        // filter out layers that don't have the leaflet.pm instance
        layers = layers.filter(function (layer) {
            return !!layer.pm;
        });

        // filter out everything that's leaflet.pm specific temporary stuff
        layers = layers.filter(function (layer) {
            return !layer._pmTempLayer;
        });

        this._globalEditMode = true;

        layers.forEach(function (layer) {
            layer.pm.enable(options);
        });

        // toggle the button in the toolbar
        this.Toolbar.toggleButton('editPolygon', this._globalEditMode);
    },
    disableGlobalEditMode: function disableGlobalEditMode(editLayer) {
        // find all layers handles by leaflet.pm
        var layers = [];
        if (editLayer) {
            layers.push(editLayer);
        } else {
            this.map.eachLayer(function (layer) {
                if (layer instanceof L.Polyline || layer instanceof L.Marker || layer instanceof L.Circle) {
                    layers.push(layer);
                }
            });
        }

        // filter out layers that don't have the leaflet.pm instance
        layers = layers.filter(function (layer) {
            return !!layer.pm;
        });

        // filter out everything that's leaflet.pm specific temporary stuff
        layers = layers.filter(function (layer) {
            return !layer._pmTempLayer;
        });

        this._globalEditMode = false;

        layers.forEach(function (layer) {
            layer.pm.disable();
        });

        // toggle the button in the toolbar
        this.Toolbar.toggleButton('editPolygon', this._globalEditMode);
    },
    toggleGlobalEditMode: function toggleGlobalEditMode(options) {
        if (this.globalEditEnabled()) {
            // disable
            this.disableGlobalEditMode();
        } else {
            // enable
            this.enableGlobalEditMode(options);
        }
    }
});

exports.default = Map;

/***/ })
/******/ ]);